$(function() {
//	var page = 1;
//	var tddata = ['order_no','people', 'ride_time','departure', 'destination','orderstate', 'paytype_price'];
//	var addoperation = `<td>
//			<div class="tpl-table-black-operation">
//				<a class="details" href="javascript:;">
//					<i class="am-icon-pencil"></i> 详情
//				</a>
//				
//				<a class="showmap" data-method="showmap" href="javascript:;">
//					<i class="am-icon-map"></i> 轨迹
//				</a>
//			</div>
//		</td>`;
	var limitall;
		$.ajax({
		type: "post",
		url: "{:url('unit/limit/all')}",
		success: function(res) {
			console.log(res)
			limitall=res.data
			for(var i=0;i<limitall.length;i++){
				if(limitall[i].state==1){
					limitall[i].state_main='启用中'
				}else{
					limitall[i].state_main='禁用中'
				}
				limitall[i].limit_rule=JSON.parse(limitall[i].limit_rule)
				if(limitall[i].limit_type==2){
					limitall[i].limittype='财政'
					if(limitall[i].limit_rule.need_check){
						limitall[i].need_check='需审批'
					}else{
						limitall[i].need_check='不需审批'
					}
				}else{
					limitall[i].limittype='单位'
					limitall[i].need_check='需审批'
				}
			}
		}
		})
		
		
		
//		
	$.ajax({
		type: "post",
		url: "{:url('order/cartypes')}",
		success: function(res) {
			var cartypelist=`<option value="0">车型-全部</option>`;
			for(var key  in res.data){ 
				{if $Think.get.car_type_id}
				if(key=={$Think.get.car_type_id}){
					cartypelist+=`<option selected value="${key}">${res.data[key]}</option>`
				}else{
					cartypelist+=`<option value="${key}">${res.data[key]}</option>`
				}
				{else/}
					cartypelist+=`<option value="${key}">${res.data[key]}</option>`
				{/if}
				}
			$('.car_type_id').html(cartypelist)
			
			var cartypeindex;
				
			
		}
	})
	
	
	
	var url={
		api:{
			delete:"{:url('adminapi/Order/orderList')}",
			list:"{:url('adminapi/Order/orderList')}",
		},
		path:{
			detail:"{:url('/admin/driver/detail')}"
		}
		
		
	}
	
	var page=1;
	var tddata=[
		{
			key:'order_no',
			type:1,
			url:''
		},{
			key:'people',
			type:1,
			url:'{:url("detail")}',
			id:137
		},{
			key:'ride_time',
			type:1,
			url:''
		},{
			key:'from_addr',
			type:1,
			url:''
		},{
			key:'to_addr',
			type:1,
			url:''
		},{
			key:'orderstate',
			type:1,
			url:''
		},{
			key:'paytype_price',
			type:1,
			url:''
		}];
	var addoperation = `<td>
			<div class="tpl-table-black-operation">
				<a class="details" href="javascript:;">
					<i class="am-icon-pencil"></i> 详情
				</a>
				
				<a class="showmap" data-method="showmap" href="javascript:;">
					<i class="am-icon-map"></i> 轨迹
				</a>
			</div>
		</td>`;
    var data={};
    data.page=page;
    data.pagenum=10;
    var where_json={};
    {if $Think.get.passenger_name}
		where_json.passenger_name=['like','%{$Think.get.passenger_name}%']
	{/if}
	{if $Think.get.passenger_phone}
		where_json.passenger_phone=['like','%{$Think.get.passenger_phone}%']
	{/if}
	{if $Think.get.order_no}
		where_json.order_no=['like','%{$Think.get.order_no}%']
	{/if}
	{if $Think.get.start_date}
		where_json.ride_time=['between time',["{$Think.get.start_date}","{$Think.get.end_date}"]]
	{/if}
	{if $Think.get.car_type_id}
		where_json.car_type_id=['in','{$Think.get.car_type_id}']
	{/if}
	{if $Think.get.order_start}
		where_json.apply_time=['between time',['{$Think.get.order_start}','{$Think.get.order_end}']]
	{/if}
	{if $Think.get.use_type}
		where_json.use_type=['in','{$Think.get.use_type}']
	{/if}
	{if $Think.get.pay_type}
		where_json.pay_type=['in','{$Think.get.pay_type}']
	{/if}
	where_json.company_id=['in',$('.company_all_id').val()]
	data.where_json=JSON.stringify(where_json)
	console.log(data)
	ajaxorder(data)
    function ajaxorder(data){
    	Load()
    	$.ajax({
		type: "post",
		url: url.api.list,
		data: data,
		success: function(res) {
			Load(1)
			console.log(res);
			console.log(res);
			$("#loading-first").fadeOut(500);
			Load(1)
			if(res.code==1){
				
				var orderlist = res.data;
				for(var ii = 0; ii < orderlist.length; ii++) {
					if(orderlist[ii].use_type) {
						orderlist[ii].use_type = orderlist[ii].use_type
					} else {
	
					}
					if(orderlist[ii].pay_type == 1) {
						orderlist[ii].paytype = "个人支付";
					} else if(orderlist[ii].pay_type == 2) {
						orderlist[ii].paytype = "单位支付";
					} else if(orderlist[ii].pay_type == 3) {
						orderlist[ii].paytype = "财政支付";
					} else {
						orderlist[ii].paytype = "暂无支付方式";
					}
					if(orderlist[ii].orderer==orderlist[ii].passenger_name){
						orderlist[ii].people=orderlist[ii].passenger_name+" "+orderlist[ii].passenger_phone
					}else{
						orderlist[ii].people=orderlist[ii].orderer+'/'+orderlist[ii].passenger_name+" "+orderlist[ii].passenger_phone
					}
					var priver;
					if(orderlist[ii].passenger_money){
						priver=orderlist[ii].passenger_money;
					}else{
						priver=0;
					}
					orderlist[ii].paytype_price=orderlist[ii].paytype+':'+priver+'元'
					if(orderlist[ii].use_type == 1) {
						orderlist[ii].usetype = "行政执法";
					} else if(orderlist[ii].use_type == 2) {
						orderlist[ii].usetype = "特殊公务";
					} else if(orderlist[ii].use_type == 3) {
						orderlist[ii].usetype = "重要会议";
					} else if(orderlist[ii].use_type == 4) {
						orderlist[ii].usetype = "机要通讯"
					} else if(orderlist[ii].use_type == 5) {
						orderlist[ii].usetype = "视察调研"
					} else if(orderlist[ii].use_type == 6) {
						orderlist[ii].usetype = "公务接待"
					} else if(orderlist[ii].use_type == 7) {
						orderlist[ii].usetype = "应急公务"
					} else if(orderlist[ii].use_type == 8) {
						orderlist[ii].usetype = "紧急就医"
					} else {
						orderlist[ii].usetype = "暂无数据"
					}
					if(orderlist[ii].order_state==1){
						orderlist[ii].orderstate='待审批'
					}else if(orderlist[ii].order_state==2){
						orderlist[ii].orderstate='已批准'
					}else if(orderlist[ii].order_state==3){
						orderlist[ii].orderstate='已拒绝'
					}else if(orderlist[ii].order_state==4){
						orderlist[ii].orderstate='待用车'
					}else if(orderlist[ii].order_state==5){
						orderlist[ii].orderstate='已派车'
					}else if(orderlist[ii].order_state==6){
						orderlist[ii].orderstate='接驾中'
					}else if(orderlist[ii].order_state==7){
						orderlist[ii].orderstate='已到达出发地'
					}else if(orderlist[ii].order_state==8){
						orderlist[ii].orderstate='已到达目的地'
					}else if(orderlist[ii].order_state==9){
						orderlist[ii].orderstate='待支付'
					}else if(orderlist[ii].order_state==10){
						orderlist[ii].orderstate='待评价'
					}else if(orderlist[ii].order_state==11){
						orderlist[ii].orderstate='已完成'
					}else if(orderlist[ii].order_state==12){
						orderlist[ii].orderstate='已取消'
					}else if(orderlist[ii].order_state==13){
						orderlist[ii].orderstate='已终止'
					}else if(orderlist[ii].order_state==14){
						orderlist[ii].orderstate='无效'
					}
				}
				$('tbody').html(tbodymainf2(orderlist, 1, tddata, addoperation, 'order_id'))
				$('.pagination').html(pagechang1(res.count, 10, page))
				$(".export").on('click',function(){
					
					var tddata2=[
					{key:'order_no'},
					{key:'passenger_name'},
					{key:'orderer'},
					{key:'ride_time'},
					{key:'from_addr'},
					{key:'to_addr'},
					{key:'order_state'},
					{key:'use_type'},
					{key:'pay_type'}
					];
					
					exports(res,tddata2,data,"{:url('adminapi/Passenger/downLoadDriverList')}")
				})
				$('tbody tr').each(function(){
					for(var ii=0;ii<orderlist.length;ii++){
						if($(this).data('id')==orderlist[ii].order_id){
							if(orderlist[ii].order_state==2||orderlist[ii].order_state==4){
								$(this).find('.tpl-table-black-operation').append(`
									<a class="dispatch" href="javascript:;">
										<i class="am-icon-pencil"></i> 派车
									</a>`)
							}
							if(orderlist[ii].order_state==1){
//								$(this).find('.tpl-table-black-operation').append(`
//									<a class="check" href="javascript:;">
//										<i class="am-icon-pencil"></i> 审批
//									</a>`)
							}
						}
					}
				})
				$('.dispatch').on('click',function(){
					window.location.href='{:url("dispatch")}?order_id='+$(this).closest('tr').data('id')
				})
				$(".showmap").on('click', function() {
					popup(this)
					var that = this
					if($(this).data('method') == "showmap") {
						var trackload = layer.load(1, {
							shade: [0.1, '#fff'] //0.1透明度的白色背景
						});
						var map = new AMap.Map('showlocation', {
							resizeEnable: true,
							zoom: 8,
							center: [118.57, 24.82]
						});
						AMapUI.load(['ui/misc/PathSimplifier'], function(PathSimplifier) {
							var pathSimplifierIns = new PathSimplifier({
								zIndex: 100,
								map: map, //所属的地图实例
								getPath: function(pathData, pathIndex) {
									//返回轨迹数据中的节点坐标信息，[AMap.LngLat, AMap.LngLat...] 或者 [[lng|number,lat|number],...]
									return pathData.path;
								},
								getHoverTitle: function(pathData, pathIndex, pointIndex) {
									//返回鼠标悬停时显示的信息
									if(pointIndex >= 0) {
										//鼠标悬停在某个轨迹节点上
										return pathData.name + '，点:' + pointIndex + '/' + pathData.path.length;
									}
									//鼠标悬停在节点之间的连线上
									return pathData.name + '，点数量' + pathData.path.length;
								},
								renderOptions: {
									//轨迹线的样式
									pathLineStyle: {
										strokeStyle: 'red',
										lineWidth: 6,
										dirArrowStyle: true
									}
								}
							});
							$.ajax({
								type: "post",
								url: "{:url('/admin/order/getTrack')}",
								data: {
									oid: $(that).closest('tr').data('id')
								},
								success: function(res) {
									layer.close(trackload);
									var allpath = []
									var speed = 0;
									if(typeof res == 'string') {
										var opath1 = JSON.parse(res).data;
									} else {
										var opath1 = res.data;
									}
									var opath2 = [];
									var opath = [];
									//根据时间进行排序
									if(opath1.length > 1) {
										for(var rankidx = 0; rankidx < opath1.length; rankidx++) {
											opath2.push(opath1[rankidx].time)
										}
										opath2.sort()
										for(var k = 0; k < opath2.length; k++) {
											for(var j = 0; j < opath1.length; j++) {
												if(opath2[k] == opath1[j].time) {
													opath.push(opath1[j])
												}
											}
										}
										console.log(opath)

										for(var oi = 0; oi < opath.length; oi++) {
											var oarr = []
											oarr.push(opath[oi].longitude)
											oarr.push(opath[oi].latitude)
											allpath.push(oarr)
										}
										initPage(PathSimplifier, pathSimplifierIns, map, allpath)
									} else {
										Err('暂无轨迹信息')
									}
								},
								error: function() {
									layer.close(carload);
									Err('请求失败')
								}
							});
						})
					}
				});
				$('.details').on('click', function() {
					detail($(this).closest('tr').data('id'), orderlist);
					
				});
				$('.laquo').on('click', function() {
					page-=1;
					data.page=page
					ajaxorder(data)
					
				});
				$('.pageli').on('click', function() {
					page=$(this).html()
						data.page=page
					ajaxorder(data);
					
				});
				$('.raquo').on('click', function() {
					page+=1;
					data.page=page
					ajaxorder(data);
					
				});
			}
			
		},
		error: function() {
			Load(1)
			$("#loading-first").fadeOut(500);
		}
		})
    }
    
    
	


	$("input[type='date']").on('change', function() {

		var date1 = $(this).closest('.date_size').find("input[type='date']").eq(0).val();
		var date2 = $(this).closest('.date_size').find("input[type='date']").eq(1).val();
		if(date1) {
			if(date2) {
				if(date1 < date2) {} else {
					Err('开始时间不能在结束时间之后');
					$(this).val('');
				}
			}
		}
	})

	function detail(id) {
		console.log(id)
		var load = layer.load(0, {
			shade: [0.3, '#fff']
		});
		
		$.ajax({
			type: "post",
			url: "{:url('detail')}",
			data: {
				order_id: id
			},
			success: function(res) {
				$.ajax({
					type: "post",
					url: "{:url('unit/staff/detail')}",
					data:{
						passenger_id:res.data.passenger_id
					},
					success: function(res1) {
					var limitid=res1.data.limit_id
					
					for(var limitidx=0;limitidx<limitall.length;limitidx++){
						if(limitall[limitidx].limit_id==limitid){
							res.data.limit=limitall[limitidx]
						}
					}
					
				console.log(res)
				res.data.use_type = res.data.use_type - 0 + 1
				if(res.data.use_type == 1) {
					res.data.usetype = '行政执法';
				} else if(res.data.use_type == 2) {
					res.data.usetype = '特殊公务';
				} else if(res.data.use_type == 3) {
					res.data.usetype = '重要会议';
				} else if(res.data.use_type == 4) {
					res.data.usetype = '机要通讯';
				} else if(res.data.use_type == 5) {
					res.data.usetype = '视察调研';
				} else if(res.data.use_type == 6) {
					res.data.usetype = '公务接待';
				} else if(res.data.use_type == 7) {
					res.data.usetype = '应急公务';
				} else if(res.data.use_type == 8) {
					res.data.usetype = '紧急就医';
				} else {
					res.data.usetype = '无用车类型';
				};
				console.log(res)
				var travel_fee;
				var use_time="";
				var count_time=0;
				if(res.data.meter){
					travel_fee=parseInt(res.data.meter/1000*100)/100;
				}else{
					travel_fee=0;
				}
				if(res.data.use_time){
					if(parseInt(res.data.use_time/3600)==0){
						count_time=res.data.use_time
					}else{
						use_time=parseInt(res.data.use_time/3600)+'小时'
						count_time=res.data.use_time-(parseInt(res.data.use_time/3600)*3600)
					}
					console.log(use_time)
					if(parseInt(count_time/60)==0){
						use_time+=count_time+'秒'
					}else{
						use_time+=parseInt(count_time/60)+'分钟';
						use_time+=count_time-(parseInt(count_time/60)*60)+'秒'
					}
//				(res.data.meter/3600;)
				}else{
					use_time=0;
				}
				var wire='········································································';
				layer.close(load);
				var index = layer.open({
					title: false,
					type: 1,
					skin: 'layui-layer-rim', //加上边框
					area: ['50%', '80%'], //宽高
					content: `<div class="am-u-sm-12" style="padding:20px">
							<div class="am-u-sm-12 cl-p">
								<fieldset class="cl-p cl-m">
									<legend>订单详情</legend>
								</fieldset>
							</div>
							<div class="am-u-sm-12 cl-p">
								<div class="am-u-sm-12" style="height:275px;border: 1px solid #ccc;">
									<div id='map' style='width:100%;height:100%'></div>
								</div>
								<div class="am-u-sm-12" style='padding-top:10px'>
									<div class='order_detail_h2'>行程信息</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">乘车人:</div>${res.data.passenger_name}
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">车型:</div>${res.data.car_type_name}
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">时长:</div>${use_time?use_time:'0'}
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">出发地:</div><div class='am-fl' style='max-width:300px;overflow:auto'>${res.data.from_addr?res.data.from_addr:'暂无数据'}</div>
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">目的地:</div><div class='am-fl' style='max-width:300px;overflow:auto'>${res.data.to_addr?res.data.to_addr:'暂无数据'}</div>
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">订单编号:</div>${res.data.order_no}
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">下单时间:</div>${res.data.order_time}
									</div>
								</div>
								<div class="am-u-sm-12" style='padding-top:10px'>
									<div class='order_detail_h2'>计价信息</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">起步价:</div>${res.data.start_fee?res.data.start_fee:0}元
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">里程费:</div>${res.data.travel_fee?res.data.travel_fee:0}元(${travel_fee}公里)
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">时长费:</div>${res.data.time_fee?res.data.time_fee:'0小时'}元(${use_time})
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">路桥费:</div>${res.data.toll?res.data.toll:0}元
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">等待费:</div>${res.data.wait_fee?res.data.wait_fee:0}元
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">远途费:</div>${res.data.remote_fee?res.data.remote_fee:0}元
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">高速费:</div>${res.data.high_fee?res.data.high_fee:0}元
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">夜间行驶费:</div>${res.data.night_fee?res.data.night_fee:0}元
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">取消费:</div>${res.data.cancel_fee?res.data.cancel_fee:0}元
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">停车费:</div>${res.data.park_fee?res.data.park_fee:0}元
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">低速行驶费:</div>${res.data.low_fee?res.data.low_fee:0}元
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">其他费用:</div>${res.data.other_fee?res.data.other_fee:0}元
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">总计费用:</div>${res.data.passenger_money?res.data.passenger_money:'0'}元
									</div>
									
								</div>
								<div class="am-u-sm-12"  style='padding-top:10px'>
									<div class='order_detail_h2'>跟进信息</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">申请时间:</div>${res.data.apply_time?res.data.apply_time:'--'}
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">批准时间:</div>${res.data.approval_time?res.data.approval_time:'--'}
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">接单时间:</div>${res.data.orders_time?res.data.orders_time:'--'}
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">到达时间:</div>${res.data.arrival_time?res.data.arrival_time:'--'}
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">乘车时间:</div>${res.data.go_time?res.data.go_time:'--'}
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">支付时间:</div>${res.data.payment_time?res.data.payment_time:'--'}
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">完成时间:</div>${res.data.arrival_time?res.data.arrival_time:'--'}
									</div>
								</div>
								<div class="am-u-sm-12"  style='padding-top:10px'>
									<div class='order_detail_h2'>审批信息</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">申请时间:</div>${res.data.apply_time?res.data.apply_time:'暂无数据'}
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">审批时间:</div>${res.data.approval_time?res.data.approval_time:'暂无数据'}
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">审批员:</div>${res.data.approval?res.data.approval:'无审批员'}
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">用车类型:</div>${res.data.usetype}
									</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">用车说明:</div>${res.data.use_explain?res.data.use_explain:'无用车说明'}
									</div>
									
								</div>
								<div class="am-u-sm-12" style='padding-top:10px'>
									<div class='order_detail_h2'>用车权限</div>
									<div class="am-u-sm-12 cl-p order_detail_text">
										<div class="detail-list">用车权限:</div>${res.data.limit?res.data.limit.limit_name:'-'}
									</div>
									
								</div>
							</div>
						</div>`,
					success: function(res) {
						var qd = [118.57, 24.82];
						var map = new AMap.Map('map', {
							resizeEnable: true,
							zoom: 13,
							center: qd
						});
						AMapUI.load(['ui/misc/PathSimplifier'], function(PathSimplifier) {
							var pathSimplifierIns = new PathSimplifier({
								zIndex: 100,
								map: map, //所属的地图实例
								getPath: function(pathData, pathIndex) {
									//返回轨迹数据中的节点坐标信息，[AMap.LngLat, AMap.LngLat...] 或者 [[lng|number,lat|number],...]
									return pathData.path;
								},
								getHoverTitle: function(pathData, pathIndex, pointIndex) {
									//返回鼠标悬停时显示的信息
									if(pointIndex >= 0) {
										//鼠标悬停在某个轨迹节点上
										return pathData.name + '，点:' + pointIndex + '/' + pathData.path.length;
									}
									//鼠标悬停在节点之间的连线上
									return pathData.name + '，点数量' + pathData.path.length;
								},
								renderOptions: {
									//轨迹线的样式
									pathLineStyle: {
										strokeStyle: 'red',
										lineWidth: 6,
										dirArrowStyle: true
									}
								}
							});
							var trackload = layer.load(1, {
								shade: [0.1, '#fff'] //0.1透明度的白色背景
							});
							$.ajax({
								type: "post",
								url: "{:url('/admin/order/getTrack')}",
								data: {
									oid:id
								},
								success: function(res) {
									layer.close(trackload);
									var allpath = []
									var speed = 0;
									if(typeof res == 'string') {
										var opath1 = JSON.parse(res).data;
									} else {
										var opath1 = res.data;
									}
									var opath2 = [];
									var opath = [];
									//根据时间进行排序
									if(opath1.length > 1) {
										for(var rankidx = 0; rankidx < opath1.length; rankidx++) {
											opath2.push(opath1[rankidx].time)
										}
										opath2.sort()
										for(var k = 0; k < opath2.length; k++) {
											for(var j = 0; j < opath1.length; j++) {
												if(opath2[k] == opath1[j].time) {
													opath.push(opath1[j])
												}
											}
										}
										console.log(opath)

										for(var oi = 0; oi < opath.length; oi++) {
											var oarr = []
											oarr.push(opath[oi].longitude)
											oarr.push(opath[oi].latitude)
											allpath.push(oarr)
										}
										initPage(PathSimplifier, pathSimplifierIns, map, allpath)
									} else {
										Err('暂无轨迹信息')
									}
								},
								error: function() {
									layer.close(carload);
									Err('请求失败')
								}
							});
						})
					}
				});
				}
				})
			}
		})
	}

	function initPage(PathSimplifier, pathSimplifierIns, map, path) {
		var alljourney = 0
		for(var pidx = 0; pidx < path.length - 1; pidx++) {
			var journey = Math.sqrt(Math.pow((path[pidx][0] - path[pidx + 1][0]), 2) + Math.pow((path[pidx][1] - path[pidx + 1][1]), 2)) * 111000
			alljourney += journey
		}

		console.log(alljourney)
		//这里构建两条简单的轨迹，仅作示例
		pathSimplifierIns.setData([{
			name: '轨迹',
			path: path
		}]);

		//创建一个巡航器
		var navg0 = pathSimplifierIns.createPathNavigator(0, //关联第1条轨迹
			{
				loop: true, //循环播放
				speed: alljourney / 10,
				pathNavigatorStyle: {
					width: 16,
					height: 32,
					content: PathSimplifier.Render.Canvas.getImageContent('{$static_dir}/assets/img/car-gray.png', onload, onerror),
					strokeStyle: null,
					fillStyle: null
				}
			});

		navg0.start();
	}
})